<script>
    class Shape{
        get width(){
            return this._width;
        }
        set width(value){
            if(value>0){
                this._width=value;
            }else{
                throw '宽度必须大于0';
            }
        }
    }

    let s1=new Shape();
    console.log(s1.width);
    s1.width=100;
    s1._width=-100;
    console.log(s1.width);
    s1.width=-100;
    console.log(s1.width);
</script>